package com.atguigu.crowd.service.impl;

import com.atguigu.crowd.entity.Auth;
import com.atguigu.crowd.entity.AuthExample;
import com.atguigu.crowd.mapper.AuthMapper;
import com.atguigu.crowd.service.AuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 权限分配的业务接口实现类
 *
 * @author wmb
 *
 * @since 2021-1-25
 */
@Service("authService")
public class AuthServiceImpl implements AuthService {

    @Autowired
    @Qualifier("authMapper")
    private AuthMapper authMapper;

    /**
     * 获取所有权限的用户
     *
     * @return
     */
    @Override
    public List<Auth> getAll() {
        return authMapper.selectByExample(new AuthExample());
    }

    /**
     * 根据roleId获取权限
     *
     * @param roleId
     *
     * @return
     */
    @Override
    public List<Integer> getAssignAuthIdByRoleId(Integer roleId) {
        return authMapper.selectAssignedAuthIdByRoleId(roleId);
    }

    /**
     * 根据adminId获取权限名称
     *
     * @param adminId
     *
     * @return
     */
    @Override
    public List<String> getAssignedAuthNameByAdminId(Integer adminId) {
        return authMapper.selectAssignedAuthNameByAdminId(adminId);
    }
}
